API Documentation
Public Member Functions | Public Attributes | List of all members
nkGraphics::ImageData Class Reference

Holds an image data and its description in memory. More...

Public Member Functions

 ImageData ()
 
 ImageData (ImageData &&other)
 
 ~ImageData ()
 
nkMaths::Vector getPixelAt (unsigned int xPix, unsigned int yPix)
 
void setPixelAt (unsigned int xPix, unsigned int yPix, const nkMaths::Vector &color)
 
bool exportToFileAsBmp (const char *path)
 
ImageDataoperator= (ImageData &&other)
 

Public Attributes

unsigned char * _data = nullptr
 The image data.
 
unsigned int _width = 0
 The width of the image, in pixels.
 
unsigned int _height = 0
 The height of the image, in pixels.
 
unsigned int _rowByteSize = 0
 The size, in byte, of one row of the image. It can be different from _width * sizeof(format), for memory alignment purpose. Always check this member for safe reading, if not using the methods.
 
FORMAT _imageFormat = R8G8B8A8_UNORM
 The format of the image data.
 

Detailed Description

Holds an image data and its description in memory.

Currently meant as a data holder returned by other classes for easo of access. It owns the memory attached to it.

Constructor & Destructor Documentation

◆ ImageData() [1/2]

nkGraphics::ImageData::ImageData ( )

Default constructor.

◆ ImageData() [2/2]

nkGraphics::ImageData::ImageData ( ImageData &&  other)

Move constructor.

◆ ~ImageData()

nkGraphics::ImageData::~ImageData ( )

Destructor.

Member Function Documentation

◆ getPixelAt()

nkMaths::Vector nkGraphics::ImageData::getPixelAt ( unsigned int  xPix,
unsigned int  yPix 
)

Returns the pixel value at given coordinates.

Parameters
xPixThe x coordinate of the pixel.
yPixThe y coordinate of the pixel.
Returns
The requested pixel's value.

◆ setPixelAt()

void nkGraphics::ImageData::setPixelAt ( unsigned int  xPix,
unsigned int  yPix,
const nkMaths::Vector color 
)

Forces a pixel value.

Parameters
xPixThe x coordinate of the pixel.
yPixThe y coordinate of the pixel.
colorThe color to set. It has to be consistent with the format.

◆ exportToFileAsBmp()

bool nkGraphics::ImageData::exportToFileAsBmp ( const char *  path)

Exports the data in a bmp file.

Parameters
pathThe path to export to, absolute or relative to the execution path.

◆ operator=()

ImageData& nkGraphics::ImageData::operator= ( ImageData &&  other)

Equality operator.

Parameters
otherThe other image data to copy.

The documentation for this class was generated from the following file: